package com.wdh.kjs.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.wdh.kjs.R;
import com.wdh.kjs.http.Httpurl;
import com.wdh.kjs.model.JsonModel_my;
import com.wdh.kjs.util.ToastUtils;

/**
 * Created by CQH on 2016/4/21.
 */
public class RealNameAuthPerSubActivity extends BaseTopActivity implements View.OnClickListener {
    private TextView TextView_auth_per_pName;
    private TextView TextView_auth_per_pIdNum;
    private String partyId;
    private JsonModel_my jsonModel_my;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.real_name_auth_per_sub);
        SharedPreferences sharedPreferences = getSharedPreferences("logininfo",MODE_PRIVATE);
        partyId = sharedPreferences.getString("loginToken", "");
        initTopBar("实名认证");
        initview();
        loadData();
    }

    private void loadData() {
        RequestParams params = new RequestParams();
        params.addBodyParameter("partyId", partyId);

        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, Httpurl.URL_REALAUTH_PER_INFO, params, new RequestCallBack<String>() {

            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {

                Gson gson = new Gson();
                jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);

                if (jsonModel_my.success) {
                    TextView_auth_per_pName.setText(jsonModel_my.getRealAuthInfo().getpName());
                    TextView_auth_per_pIdNum.setText(jsonModel_my.getRealAuthInfo().getpIdNum());
                }
            }
            @Override
            public void onFailure(HttpException error, String msg) {
                ToastUtils.showShort(getApplicationContext(), "网络异常！");
            }
        });
    }

    private void initview() {
        TextView_auth_per_pName = (TextView)findViewById(R.id.TextView_auth_per_pName);
        TextView_auth_per_pIdNum = (TextView)findViewById(R.id.TextView_auth_per_pIdNum);
    }

    public void onClick(View v) {

    }
}